<div [@routerTransition]>
    <div class="content d-flex flex-column flex-column-fluid">

        <sub-header [title]="'Room' | localize" [description]="'Room' | localize">
            <div role="actions"></div>
        </sub-header>

        <div [class]="containerClass ">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <div class="row">
                        <form class="horizontal-form" autocomplete="off">
                            
                                <div class="row align-items-center mb-4">
                                    <div class="col-2">
                                        <div class="form-group m-form__group align-items-center">
                                            <label>{{l('name')}}</label>
                                            <div class="input-group">
                                                <input [(ngModel)]="filterText" name="filterText" autoFocus
                                                    class="form-control m-input" (keyup.enter)="getList()"
                                                    [placeholder]="l('SearchWithThreeDot')" type="text">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-2">
                                        <div class="form-group m-form__group align-items-center">
                                            <label>{{l('Building')}}</label>
                                            <div class="input-group">
                                                <select class="form-control" [(ngModel)]="buildingId" name="buildingId"
                                                    (change)="getFloor4Select()">
                                                    <option value="">
                                                        {{l("All")}}{{l("Building")}}</option>
                                                    <option *ngFor="let building of buildingList" [value]="building.id">
                                                        {{building.name}}</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-2">
                                        <div class="form-group m-form__group align-items-center">
                                            <label>{{l('Floor')}}</label>
                                            <div class="input-group">
                                                <select class="form-control" [(ngModel)]="floorId" name="floorId"
                                                    [disabled]="!buildingId">
                                                    <option value="">
                                                        {{l("All")}}{{l("Floor")}}</option>
                                                    <option *ngFor="let floor of floorList" [value]="floor.id">
                                                        {{floor.name}}</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-2">
                                        <div class="form-group m-form__group align-items-center">
                                            <label>&nbsp;</label>
                                            <div class="input-group">
                                                <button type="button" class="btn btn-primary"
                                                    [buttonBusy]="primengTableHelper.isLoading" (click)="getList()">
                                                    <i class="la la-refresh"></i>
                                                    {{l("search")}}
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-4 text-right">
                                        <button class="btn btn-primary" (click)="goImport()">
                                            <i class="icon-excel"></i> {{l('import')}} </button>
                                        <button type="button" (click)="deleteBatch()" class="btn btn-primary blue">
                                            <i class="icon-piliangcaozuo"></i> {{l("deleteBatch")}}</button>
                                        <button type="button" (click)="createItem()" class="btn btn-primary blue">
                                            <i class="fa fa-plus"></i>{{l("add")}}{{l("Room")}}</button>
                                    </div>
                                </div>
                            
                        </form>
                    </div>
                    <div class="row align-items-center">
                        <!--<Primeng-Datatable-Start>-->
                        <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                            <p-table #dataTable (onLazyLoad)="getList($event)" [value]="primengTableHelper.records"
                                [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false" [lazy]="true"
                                [resizableColumns]="primengTableHelper.resizableColumns" [(selection)]="selectedList"
                                [responsive]="primengTableHelper.isResponsive">
                                <ng-template pTemplate="header">
                                    <tr>
                                        <th style="width: 15%">{{l('Actions')}}</th>
                                        <th style="width: 5%">
                                            <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                                        </th>
                                        <th style="width:5%">{{l('RecordId')}}</th>
                                        <th>{{l('name')}}</th>
                                        <th>{{l('type')}}</th>
                                        <th>{{l('itemId')}}</th>
                                        <th>{{l('Building')}}</th>
                                        <th>{{l('Floor')}}</th>
                                        <!-- <th>{{l('width')}}</th> -->
                                        <!-- <th>{{l('height')}}</th> -->
                                        <th>{{l('Brand')}}</th>
                                        <th>{{l('Store')}}</th>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-record let-i="rowIndex">
                                    <tr [pSelectableRow]="record" [attr.trid]="record.id">
                                        <td>
                                            <div class="btn-group dropdown" dropdown normalizePosition>
                                                <button class="dropdown-toggle btn btn-sm btn-primary"
                                                    data-toggle="dropdown" dropdownToggle aria-haspopup="true"
                                                    aria-expanded="false">
                                                    <i class="fa fa-cog"></i>
                                                    <span class="caret"></span> {{l("Actions")}}
                                                </button>
                                                <ul class="dropdown-menu" *dropdownMenu>
                                                    <li>
                                                        <a class="icon-bianji dropdown-item"
                                                            (click)="editItem(record)">{{l('Edit')}}</a>
                                                    </li>
                                                    <li>
                                                        <a class="icon-icon-test dropdown-item"
                                                            (click)="deleteItem(record)">{{l('Delete')}}</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                        <td>
                                            <p-tableCheckbox [value]="record"></p-tableCheckbox>
                                        </td>
                                        <td style="width:5%"> {{transIndex(i)}}</td>
                                        <td>
                                            <span>{{record.name}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.roomType}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.no}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.buildingName}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.floorNo}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.brandName}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.storeName}}</span>
                                        </td>
                                        <!-- <td>
                                            <span>{{record.areaWidth}}</span>
                                        </td>
                                        <td>
                                            <span>{{record.areaHeight}}</span>
                                        </td> -->
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="emptymessage" let-records>
                                    <tr *ngIf="primengTableHelper.records">
                                        <td colspan="10">
                                            <img class="emptymessage"
                                                src="/assets/common/images/placeholder/deviceHolder.png" />
                                        </td>
                                    </tr>
                                </ng-template>
                            </p-table>
                            <div class="primeng-paging-container">
                                <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                    (onPageChange)="getList($event)"
                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                </p-paginator>
                                <span class="total-records-count">
                                    {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                </span>
                            </div>
                        </div>
                        <!--<Primeng-Datatable-End>-->
                    </div>
                </div>
            </div>
        </div>

        <roomModal #roomModal (modalSave)="getList()" [buildingList]="buildingList" [initBuildingId]="buildingId"
            [initFloorId]="floorId"></roomModal>
    </div>

</div>